package se.sweco.gpsservice.datatypes;

public class GPSDataGPRMC {
	String time = "";
	String status = "";
	float Latitude = 0.0f;
	String LatitudeType = "";
	float Longitude = 0.0f;
	String LongitudeType = "";
	float speed = 0.0f;
	float track = 0.0f;
	String date = "";
	float magneticVar = 0.0f;
	String MagneticVarType = "";
	String checksum = "";
	
	public void parseData(String data) {
		String[] gpsData = data.split(",");
		String gpsDataType = gpsData[0].substring(1);
		
		if(gpsDataType.equals("GPRMC")) {
			if(!gpsData[1].trim().equals(""))
				time = gpsData[1];
			if(!gpsData[2].trim().equals(""))
				status = gpsData[2];
			if(!gpsData[3].trim().equals(""))
				Latitude = new Float(gpsData[3]).floatValue();
			if(!gpsData[4].trim().equals(""))
				LatitudeType = gpsData[4];
			if(!gpsData[5].trim().equals(""))
				Longitude = new Float(gpsData[5]).floatValue();
			if(!gpsData[6].trim().equals(""))
				LongitudeType = gpsData[6];
			if(!gpsData[7].trim().equals(""))
				speed = new Float(gpsData[7]).floatValue();
			if(!gpsData[8].trim().equals(""))
				track = new Float(gpsData[8]).floatValue();
			if(!gpsData[9].trim().equals(""))
				date = gpsData[9];
			if(!gpsData[10].trim().equals(""))
				magneticVar = new Float(gpsData[10]).floatValue();
			if(!gpsData[11].trim().equals(""))
				MagneticVarType = gpsData[11];
			if(!gpsData[12].trim().equals(""))
				checksum = gpsData[12];
		}
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("Time: " + this.time + "\n");
		sb.append("Status: " + this.status + "\n");
		sb.append("Latitude: " + this.Latitude + " (" + this.LatitudeType + ")" + "\n");
		sb.append("Longitude: " + this.Longitude + " (" + this.LongitudeType + ")" + "\n");
		sb.append("Speed: " + this.speed + "\n");
		sb.append("Track: " + this.track + "\n");
		sb.append("Date: " + this.date + "\n");
		sb.append("MagneticVar: " + this.magneticVar + "\n");
		sb.append("MagneticVarType: " + this.MagneticVarType + "\n");
		return sb.toString();
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public float getLatitude() {
		return Latitude;
	}

	public void setLatitude(float latitude) {
		Latitude = latitude;
	}

	public String getLatitudeType() {
		return LatitudeType;
	}

	public void setLatitudeType(String latitudeType) {
		LatitudeType = latitudeType;
	}

	public float getLongitude() {
		return Longitude;
	}

	public void setLongitude(float longitude) {
		Longitude = longitude;
	}

	public String getLongitudeType() {
		return LongitudeType;
	}

	public void setLongitudeType(String longitudeType) {
		LongitudeType = longitudeType;
	}

	public float getSpeed() {
		return speed;
	}

	public void setSpeed(float speed) {
		this.speed = speed;
	}

	public float getTrack() {
		return track;
	}

	public void setTrack(float track) {
		this.track = track;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public float getMagneticVar() {
		return magneticVar;
	}

	public void setMagneticVar(float magneticVar) {
		this.magneticVar = magneticVar;
	}

	public String getMagneticVarType() {
		return MagneticVarType;
	}

	public void setMagneticVarType(String magneticVarType) {
		MagneticVarType = magneticVarType;
	}

	public String getChecksum() {
		return checksum;
	}

	public void setChecksum(String checksum) {
		this.checksum = checksum;
	}
	
}
